#ifndef __SC4210_CMOS_PARAM_H_
#define __SC4210_CMOS_PARAM_H_

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

#include <linux/cvi_vip_cif.h>
#include <linux/cvi_vip_snsr.h>
#include "cvi_type.h"
#include "cvi_sns_ctrl.h"
#include "sc4210_cmos_ex.h"

static const SC4210_MODE_S g_astSC4210_mode[SC4210_MODE_NUM] = {
	[SC4210_MODE_1440P30] = {
		.name = "1440p30",
		.astImg[0] = {
			.stSnsSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stMaxSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
		},
		.f32MaxFps = 30,
		.f32MinFps = 0.69, /* 0x5DC *30 / 0xFFFF */
		.u32VtsDef = 0x5DC,
		.stExp[0] = {
			.u16Min = 1,
			.u16Max = 2 * (0x5DC - 2),
			.u16Def = 400,
			.u16Step = 2,
		},
		.stAgain[0] = {
			.u16Min = 1024,
			.u16Max = 16256,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.stDgain[0] = {
			.u16Min = 1024,
			.u16Max = 32512,
			.u16Def = 1024,
			.u16Step = 1,
		},
	},
	[SC4210_MODE_1440P30_WDR] = {
		.name = "1440p30wdr",
		.astImg[0] = {
			.stSnsSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stMaxSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
		},
		.astImg[1] = {
			.stSnsSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 2560,
				.u32Height = 1440,
			},
			.stMaxSize = {
				.u32Width = 2560,
				.u32Height = 1440,
			},
		},
		.f32MaxFps = 30,
		.f32MinFps = 1.38, /* 3000 *30 / 0xFFFF */
		.u32VtsDef = 2 * 0x5DC,
		.u16SexpMax = 0x1E, //Max short exposure
	},
};

static ISP_CMOS_NOISE_CALIBRATION_S g_stIspNoiseCalibratio = {.CalibrationCoef = {
	{	// iso 100
		{0.02380375564098358154,	6.16164588928222656250}, //B: slope, intercept
		{0.02017356827855110168,	9.33144569396972656250}, //Gb: slope, intercept
		{0.02033685334026813507,	9.32166290283203125000}, //Gr: slope, intercept
		{0.02188318967819213867,	7.30588388442993164063}, //R: slope, intercept
	},
	{	// iso 200
		{0.03049315884709358215,	9.04733943939208984375}, //B: slope, intercept
		{0.02455039881169795990,	13.08980178833007812500}, //Gb: slope, intercept
		{0.02471091598272323608,	13.12132930755615234375}, //Gr: slope, intercept
		{0.02803890220820903778,	10.29580307006835937500}, //R: slope, intercept
	},
	{	// iso 400
		{0.04247752204537391663,	12.13918495178222656250}, //B: slope, intercept
		{0.03236426040530204773,	17.27832794189453125000}, //Gb: slope, intercept
		{0.03225822746753692627,	17.40349769592285156250}, //Gr: slope, intercept
		{0.03855844587087631226,	13.57517147064208984375}, //R: slope, intercept
	},
	{	// iso 800
		{0.04355118796229362488,	21.56639671325683593750}, //B: slope, intercept
		{0.03019045852124691010,	30.79609489440917968750}, //Gb: slope, intercept
		{0.02988618798553943634,	30.82164382934570312500}, //Gr: slope, intercept
		{0.04399589076638221741,	21.22332954406738281250}, //R: slope, intercept
	},
	{	// iso 1600
		{0.05362238362431526184,	24.43242263793945312500}, //B: slope, intercept
		{0.03729068115353584290,	32.80402374267578125000}, //Gb: slope, intercept
		{0.03696008399128913879,	33.05516815185546875000}, //Gr: slope, intercept
		{0.05456049740314483643,	24.16281509399414062500}, //R: slope, intercept
	},
	{	// iso 3200
		{0.08042477071285247803,	31.86009407043457031250}, //B: slope, intercept
		{0.05715733021497726440,	40.87671661376953125000}, //Gb: slope, intercept
		{0.05646869912743568420,	41.05189132690429687500}, //Gr: slope, intercept
		{0.08117594569921493530,	31.57122802734375000000}, //R: slope, intercept
	},
	{	// iso 6400
		{0.11428051441907882690,	45.03053283691406250000}, //B: slope, intercept
		{0.08113395422697067261,	55.74248123168945312500}, //Gb: slope, intercept
		{0.08189499378204345703,	55.33699798583984375000}, //Gr: slope, intercept
		{0.11583238840103149414,	44.53123474121093750000}, //R: slope, intercept
	},
	{	// iso 12800
		{0.15985357761383056641,	65.25237274169921875000}, //B: slope, intercept
		{0.11098099499940872192,	80.30263519287109375000}, //Gb: slope, intercept
		{0.11019350588321685791,	80.37381744384765625000}, //Gr: slope, intercept
		{0.16201083362102508545,	64.62660217285156250000}, //R: slope, intercept
	},
	{	// iso 25600
		{0.23384790122509002686,	91.50229644775390625000}, //B: slope, intercept
		{0.15641865134239196777,	113.87143707275390625000}, //Gb: slope, intercept
		{0.15514039993286132813,	114.00232696533203125000}, //Gr: slope, intercept
		{0.23750382661819458008,	89.58798980712890625000}, //R: slope, intercept
	},
	{	// iso 51200
		{0.37026703357696533203,	111.95485687255859375000}, //B: slope, intercept
		{0.24148342013359069824,	146.65702819824218750000}, //Gb: slope, intercept
		{0.24038283526897430420,	146.66661071777343750000}, //Gr: slope, intercept
		{0.37361314892768859863,	110.62525177001953125000}, //R: slope, intercept
	},
	{	// iso 102400
		{0.57246607542037963867,	71.47297668457031250000}, //B: slope, intercept
		{0.40686360001564025879,	94.32553100585937500000}, //Gb: slope, intercept
		{0.40248519182205200195,	94.78514862060546875000}, //Gr: slope, intercept
		{0.56791663169860839844,	71.87047576904296875000}, //R: slope, intercept
	},
	{	// iso 204800
		{0.73495632410049438477,	52.39044189453125000000}, //B: slope, intercept
		{0.58373540639877319336,	64.49837493896484375000}, //Gb: slope, intercept
		{0.58319985866546630859,	64.53244018554687500000}, //Gr: slope, intercept
		{0.73198550939559936523,	52.34358978271484375000}, //R: slope, intercept
	},
	{	// iso 409600
		{0.89165377616882324219,	39.66812896728515625000}, //B: slope, intercept
		{0.77462798357009887695,	44.97374725341796875000}, //Gb: slope, intercept
		{0.76392781734466552734,	45.77359008789062500000}, //Gr: slope, intercept
		{0.87228125333786010742,	40.79494476318359375000}, //R: slope, intercept
	},
	{	// iso 819200
		{0.89165377616882324219,	39.66812896728515625000}, //B: slope, intercept
		{0.77462798357009887695,	44.97374725341796875000}, //Gb: slope, intercept
		{0.76392781734466552734,	45.77359008789062500000}, //Gr: slope, intercept
		{0.87228125333786010742,	40.79494476318359375000}, //R: slope, intercept
	},
	{	// iso 1638400
		{0.89165377616882324219,	39.66812896728515625000}, //B: slope, intercept
		{0.77462798357009887695,	44.97374725341796875000}, //Gb: slope, intercept
		{0.76392781734466552734,	45.77359008789062500000}, //Gr: slope, intercept
		{0.87228125333786010742,	40.79494476318359375000}, //R: slope, intercept
	},
	{	// iso 3276800
		{0.89165377616882324219,	39.66812896728515625000}, //B: slope, intercept
		{0.77462798357009887695,	44.97374725341796875000}, //Gb: slope, intercept
		{0.76392781734466552734,	45.77359008789062500000}, //Gr: slope, intercept
		{0.87228125333786010742,	40.79494476318359375000}, //R: slope, intercept
	},
} };

static ISP_CMOS_BLACK_LEVEL_S g_stIspBlcCalibratio = {
	.bUpdate = CVI_TRUE,
	.blcAttr = {
		.Enable = 1,
		.enOpType = OP_TYPE_AUTO,
		.stManual = {273, 273, 273, 273, 1097, 1097, 1097, 1097},
		.stAuto = {
			{273, 273, 273, 273, 273, 272, 271, 269, /*8*/265, 258, 258, 257, 259, 258, 260, 258},
			{273, 273, 273, 273, 273, 273, 272, 271, /*8*/269, 264, 263, 264, 263, 264, 264, 263},
			{273, 273, 273, 273, 273, 272, 272, 271, /*8*/268, 261, 263, 263, 263, 262, 263, 260},
			{273, 273, 273, 273, 273, 272, 271, 270, /*8*/265, 259, 259, 258, 257, 259, 259, 258},
			{1097, 1097, 1097, 1097, 1097, 1097, 1097, 1096,
				/*8*/1095, 1093, 1093, 1093, 1093, 1093, 1093, 1093},
			{1097, 1097, 1097, 1097, 1097, 1097, 1097, 1097,
				/*8*/1096, 1095, 1094, 1095, 1094, 1095, 1095, 1094},
			{1097, 1097, 1097, 1097, 1097, 1097, 1097, 1097,
				/*8*/1096, 1094, 1094, 1094, 1094, 1094, 1094, 1093},
			{1097, 1097, 1097, 1097, 1097, 1097, 1097, 1096,
				/*8*/1095, 1093, 1093, 1093, 1093, 1093, 1093, 1093},
		},
	},
};

struct combo_dev_attr_s sc4210_rx_attr = {
	.input_mode = INPUT_MODE_MIPI,
	.mac_clk = RX_MAC_CLK_400M,
	.mipi_attr = {
		.raw_data_type = RAW_DATA_12BIT,
		.lane_id = {0, 4, 3, 2, 1},
		.wdr_mode = CVI_MIPI_WDR_MODE_VC,
		.dphy = {
			.enable = 1,
			.hs_settle = 8,
		},
	},
	.mclk = {
		.cam = 0,
		.freq = CAMPLL_FREQ_27M, //6-27MHz
	},
	.devno = 0,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */


#endif /* __SC4210_CMOS_PARAM_H_ */
